package com.acme.bankapp.domain.bank;

public class Client
{
	private Account[] accounts;
	private int numberOfAccounts;
	private int maxNumberOfAccounts;
	private String name;
	private Gender gender;
	
	public Client(final String clientName, final Gender clientSex, 
			final int accountsQuantity)
	{
		name = clientName;
		gender = clientSex;
		maxNumberOfAccounts = accountsQuantity;
		accounts = new Account[maxNumberOfAccounts];
	}
	
	public Client(final int accountsNumber)
	{
		this("<NAME>", null, accountsNumber);
	}
	
	public void addAccount(final Account newAccount)
	{
		if (numberOfAccounts < maxNumberOfAccounts)
		{
			accounts[numberOfAccounts++] = newAccount;
		}
		else
		{
			System.out.println("The maximal number " +
					"of accounts is reached.");
		}
	}
	
	public Account[] getAccounts()
	{
		return accounts;
	}
	
	public int getNumberOfAccounts()
	{
		return numberOfAccounts;
	}
	
	public void setClientName(final String clientName)
	{
		name = clientName;
	}
	
	public String getClientSalutation()
	{
		if (gender != null)
		{
			return gender.getSalutation() + " " + name;
		}
		else
		{
			return name;
		}
	}
}
